package com.kaifamiao.N0728;

import java.lang.reflect.Method;
import java.sql.SQLOutput;

// 有子必须先有父
public class Sup {
    int a = 1;
    static int b = 2;

    {
        System.out.println("Sup:{}");
    }

    static {
        System.out.println("Sup:static{}");
    }

    // super 关键字在子类中使用, 表示 父类对象。 super 调用父类的成员  super([参数列表]) 调用父类构造
    public Sup() {
        System.out.println("Sup()");
    }

    public Sup(int a) {
        System.out.println("Sup(int a)");
    }

    public void instanceMethod() {
        System.out.println("sup::instanceMethod");
    }

    public static void staticMethod() {
        System.out.println("Sup::StaticMethod");
    }
}

class Sub extends Sup {

    static int a = 3;
    int b = 4;

    {
        System.out.println("Sub:{}");
    }

    static {
        System.out.println("Sub:static{}");
    }

    public Sub() {
        System.out.println("Sub()");
    }

    public void show() {
        System.out.println("a = " + a);
        System.out.println("this.a = " + this.a);
        System.out.println("super.a = " + super.a);
        System.out.println("b = " + b);
        System.out.println("this.b = " + this.b);
        System.out.println("super.b = " + super.b);
    }

    @Override
    public void instanceMethod() {
        System.out.println("sub::instanceMethod");
    }

    public static void staticMethod() {
        System.out.println("Sub:staticMethod");
    }

}
